package com.netease.yunxin.app.im.model;

import com.google.gson.Gson;
import com.google.gson.JsonSyntaxException;
import com.netease.nimlib.sdk.msg.attachment.MsgAttachment;

/**
 * 自定义商品消息数据模型
 */
public class ProductMessage {
    
    private String productId;        // 商品ID
    private String productName;      // 商品名称
    private String productImage;     // 商品图片URL
    private String productPrice;     // 商品价格
    private String productDesc;      // 商品描述
    private String productUrl;       // 商品详情页URL
    private String sellerId;         // 卖家ID
    private String sellerName;       // 卖家名称
    
    public ProductMessage() {}
    
    public ProductMessage(String productId, String productName, String productImage, 
                         String productPrice, String productDesc, String productUrl,
                         String sellerId, String sellerName) {
        this.productId = productId;
        this.productName = productName;
        this.productImage = productImage;
        this.productPrice = productPrice;
        this.productDesc = productDesc;
        this.productUrl = productUrl;
        this.sellerId = sellerId;
        this.sellerName = sellerName;
    }
    
    // Getters and Setters
    public String getProductId() {
        return productId;
    }
    
    public void setProductId(String productId) {
        this.productId = productId;
    }
    
    public String getProductName() {
        return productName;
    }
    
    public void setProductName(String productName) {
        this.productName = productName;
    }
    
    public String getProductImage() {
        return productImage;
    }
    
    public void setProductImage(String productImage) {
        this.productImage = productImage;
    }
    
    public String getProductPrice() {
        return productPrice;
    }
    
    public void setProductPrice(String productPrice) {
        this.productPrice = productPrice;
    }
    
    public String getProductDesc() {
        return productDesc;
    }
    
    public void setProductDesc(String productDesc) {
        this.productDesc = productDesc;
    }
    
    public String getProductUrl() {
        return productUrl;
    }
    
    public void setProductUrl(String productUrl) {
        this.productUrl = productUrl;
    }
    
    public String getSellerId() {
        return sellerId;
    }
    
    public void setSellerId(String sellerId) {
        this.sellerId = sellerId;
    }
    
    public String getSellerName() {
        return sellerName;
    }
    
    public void setSellerName(String sellerName) {
        this.sellerName = sellerName;
    }
    
    /**
     * 将对象转换为JSON字符串
     */
    public String toJson() {
        return new Gson().toJson(this);
    }
    
    /**
     * 从JSON字符串创建对象
     */
    public static ProductMessage fromJson(String json) {
        try {
            return new Gson().fromJson(json, ProductMessage.class);
        } catch (JsonSyntaxException e) {
            e.printStackTrace();
            return null;
        }
    }
    
    @Override
    public String toString() {
        return "ProductMessage{" +
                "productId='" + productId + '\'' +
                ", productName='" + productName + '\'' +
                ", productImage='" + productImage + '\'' +
                ", productPrice='" + productPrice + '\'' +
                ", productDesc='" + productDesc + '\'' +
                ", productUrl='" + productUrl + '\'' +
                ", sellerId='" + sellerId + '\'' +
                ", sellerName='" + sellerName + '\'' +
                '}';
    }
} 